package com.itheima.commons.model.vo;

import cn.hutool.core.convert.Convert;
import com.itheima.commons.model.domain.Peach;
import com.itheima.commons.model.domain.UserInfo;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class PeachVo {

    private Integer id; //用户id
    private String avatar; //头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String soundUrl; //语音地址
    private Integer remainingTimes; //剩余次数

    public static PeachVo makePeachVo(Peach peach, UserInfo userInfo, Integer times){
        PeachVo peachVo = new PeachVo();
        peachVo.setId(Convert.toInt(peach.getUserId()));
        peachVo.setAvatar(userInfo.getLogo());
        peachVo.setNickname(userInfo.getNickName());
        peachVo.setGender(userInfo.getSex()==1?"man":"woman");
        peachVo.setAge(userInfo.getAge());
        peachVo.setSoundUrl(peach.getSoundUrl());
        peachVo.setRemainingTimes(times);
        return peachVo;
    }
}
